home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MCASM.RAR / MC_ASM.EXE / WROX_ASM / CH1 / PROG1_1.ASM next >
Encoding:
Assembly Source File  |  1994-11-14  |  1.5 KB  |  47 lines

  1.  
  2. ///////////////////////////////////////////////////////////
  3. Program 1.1.
  4. ///////////////////////////////////////////////////////////
  5. ; This program copies a string to video-RAM
  6. ; (in text-mode only). As a result, the string appears
  7. ; somewhere in the middle of your screen.
  8. ; Demo program for ExpAsm Chapter1 "Review of Assembly
  9. ; Language".
  10. ;
  11. .DOSSEG
  12. .MODEL small, c, os_dos, nearstack
  13.                 ; SMALL memory model, DOS, DS=SS are selected.
  14. .DATA                  ; Start of DATA segment.
  15.       Str DB 'THIS STRING HAS BEEN PRINTED FROM video-RAM$'
  16. .STACK 100h            ; Start of STACK segment.
  17. .CODE                ; Start of CODE segment.
  18. .STARTUP                ; Initialize Segment Registers.
  19.  
  20.             mov ax,0b800h        ; Copy  address of video-
  21.             mov es,ax            ; -RAM to Segment Register ES.
  22.             mov di,1620            ; Copy an offset  DI.
  23.             mov bx,OFFSET Str    ; BX contains start address
  24.                                 ; of the string Str now.
  25.             call Out_Str            ; Call the procedure Out_Str.
  26.  
  27. .EXIT 0            ; Generate the ending sequence.
  28.  
  29. Out_Str PROC NEAR            ; Start of NEAR procedure Out_Str.
  30. Lab:        mov al,[bx]            ; Copy current byte of Str to AL.
  31.             cmp al,'$'         ; Is it the end of the string?
  32.             je Exit_p        ; Yes, exit.
  33.  
  34.             mov byte ptr es:[di],al    ;Copy the current byte to
  35.                                     ;video-RAM
  36.             inc di            ; Change destination offset
  37.             inc di            ; address (two bytes higher).
  38.             inc bx            ; Change source offset address.
  39.             jmp Lab            ; Unconditional jump
  40.                             ;(to the loop start).
  41.  
  42. Exit_p:     ret                    ; Return to caller
  43. OUT_STR ENDP            ; End of procedure.
  44.  
  45. END                    ; End of program.
  46.  
  47.